\documentclass[twoside,a4paper]{article}
\usepackage{geometry}
\geometry{margin=1.5cm, vmargin={0pt,1cm}}
\setlength{\topmargin}{-1cm}
\setlength{\paperheight}{29.7cm}
\setlength{\textheight}{25.3cm}


% useful packages.
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{enumerate}
\usepackage{graphicx}
\usepackage{multicol}
\usepackage{fancyhdr}
\usepackage{layout}
\usepackage{ctex}%引入中文包
\usepackage{graphicx}
\usepackage{subfigure}


\usepackage{listings}
\usepackage{xcolor}      %代码着色宏包
\usepackage{CJK}         %显示中文宏包

\definecolor{mygreen}{rgb}{0,0.6,0}
\definecolor{mygray}{rgb}{0.5,0.5,0.5}
\definecolor{mymauve}{rgb}{0.58,0,0.82}
\lstset{
 backgroundcolor=\color{lightgray}, 
 basicstyle = \footnotesize,       
 breakatwhitespace = false,        
 breaklines = true,                 
 captionpos = b,                    
 commentstyle = \color{mygreen}\bfseries,
 extendedchars = false,             
 frame =shadowbox, 
 framerule=0.5pt,
 keepspaces=true,
 keywordstyle=\color{blue}\bfseries, % keyword style
 language = C++,                     % the language of code
 otherkeywords={string}, 
 numbers=left, 
 numbersep=5pt,
 numberstyle=\tiny\color{mygray},
 rulecolor=\color{black},         
 showspaces=false,  
 showstringspaces=false, 
 showtabs=false,    
 stepnumber=1,         
 stringstyle=\color{mymauve},        % string literal style
 tabsize=2,          
 title=\lstname                      
}


% some common command
\newcommand{\dif}{\mathrm{d}}
\newcommand{\avg}[1]{\left\langle #1 \right\rangle}
\newcommand{\difFrac}[2]{\frac{\dif #1}{\dif #2}}
\newcommand{\pdfFrac}[2]{\frac{\partial #1}{\partial #2}}
\newcommand{\OFL}{\mathrm{OFL}}
\newcommand{\UFL}{\mathrm{UFL}}
\newcommand{\fl}{\mathrm{fl}}
\newcommand{\op}{\odot}
\newcommand{\Eabs}{E_{\mathrm{abs}}}
\newcommand{\Erel}{E_{\mathrm{rel}}}

\begin{document}

\pagestyle{fancy}
\fancyhead{}
\lhead{方丹吟 3190102758}
\chead{双链表的设计与实现}
\rhead{2022.10.7}

\begin{center}
    \LARGE\songti\textbf{双链表的涉及与实现} \\%标题
    \large\kaishu\textbf{方丹吟\qquad 3190102758}%一般是我的姓名
\end{center}

\section*{一、主要实现内容}
\begin{itemize}
\item 设计双链表，实现构造、插入、删除、查找等功能，并对功能进行测试。
\end{itemize}

\section*{二、设计}
\subsection*{1.设计思路}

\begin{itemize}
\item List类及构造、插入、删除等功能的设计思路参考书上；
\item find函数：定义一个节点，从head开始遍历到tail，比较该节点的值是否与要找的值相同，如果相同，输出“is found successfully!”，同时返回迭代器，如果找不到这样的节点，则输出“is not found...”
\end{itemize}

\subsection*{2.函数代码}
\begin{itemize}
\item 输出函数 printList()
\end{itemize}
\begin{lstlisting}[caption={输出函数 printList()}]
void printList() const
{
   for (Node* it = head->next ; it->next != nullptr; it = it->next)
   std::cout<< it->data <<"\t";
   std::cout<<"\b"<<std::endl;
}
\end{lstlisting}


\begin{itemize}
\item 查找函数 find()
\begin{lstlisting}[caption={查找函数 find()}]

List < int >:: iterator find(List < int >& _list , int _val )
 {
    for (List<int>::Node* it = _list.head->next ; it->next != nullptr; it = it->next )
    {
    if (it->data == _val)
    {
        std::cout<<_val<<" is found successfully!"<<std::endl;
        return List< int >:: iterator(it);}
    }
    std::cout<<_val<<" is not found..."<<std::endl;
    return _list.end();
 };


\end{lstlisting}
\end{itemize}






%\subsection*{} 

\section*{三、结果报告}
\begin{itemize}
\item main函数如下
\end{itemize}


\begin{lstlisting}[caption={main.cpp}]
#include <iostream>   
#include <cstdlib>
#include "doublelinklist.h"
int main()
{
    List<int> doublelink;
    doublelink.printList();
    doublelink.push_back(1);
    doublelink.push_back(2);
    doublelink.push_back(3);
    doublelink.push_back(4);
    doublelink.push_back(5);
    doublelink.printList();
    List<int>::iterator  iter = find(doublelink,3);
    doublelink.erase(iter);
    find(doublelink,3);
    doublelink.printList();
    
    return 0;
};
\end{lstlisting}




\end{document}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 
